/** ###################################################################
**     Filename  : test.C
**     Project   : test
**     Processor : 56F8013VFAE
**     Version   : Driver 01.14
**     Compiler  : Metrowerks DSP C Compiler
**     Date/Time : 2012-3-24, 13:23
**     Abstract  :
**         Main module.
**         This module contains user's application code.
**     Settings  :
**     Contents  :
**         No public methods
**
** ###################################################################*/
/* MODULE test */


/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "Term1.h"
#include "Inhr1.h"
#include "AD1.h"
#include "PWM1.h"
#include "PWM2.h"
#include "TI1.h"
#include "EInt1.h"
#include "EInt2.h"
#include "EInt3.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

extern word *ADvalue;
uint8_t *ch;
int flag;

void main(void)
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */
  flag=0;

  AD1_Enable();
  AD1_Start();
//  EInt1_Enable();
 // EInt2_Enable();
 // EInt2_Enable();

  for(;;) {
//    AD1_GetValue16(ADvalue);
//  Term1_SendNum(*ADvalue);
// Term1_CRLF();
  
//    Cpu_Delay100US(1000);


//    Term1_ReadChar(ch);

    if(*ch=='1')
      flag=1;
    else if(*ch=='0')
      flag=0;
    else if(*ch=='2')
      flag=2;
    
    if(flag==1)
    {
    	PWM1_SetRatio16(*ADvalue);
    	PWM2_SetRatio16(0);
    }
    else if(flag==2)
    {
    	PWM1_SetRatio16(0);
    	PWM2_SetRatio16(*ADvalue);    	
    }
    else
    {
    	PWM1_SetRatio16(0);
        PWM2_SetRatio16(0);
    }  
    
  }
}

/* END test */
/*
** ###################################################################
**
**     This file was created by Processor Expert 3.00 [04.35]
**     for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
